<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;

class LoginController extends CommonController {
	protected $table = 'oo_admin';
	
    public function login(){
		
	   if (IS_POST) {
			!$this->check_verify(I('post.code'))?$this->error('验证码错误！'):'';
		   if (_getOne($this->table,I('post.'),'',1)) {		   
			   $this->redirect('index/index','登录成功！');
		   } else {
			   $this->error('账号或者密码错误！');
		   }
		   
	   } else {
		  $this->display(); 
	   }
	   
    }
	
	public function lgout(){
		session(null);
		$this->success('退出登录！');
	}
	/*
	*
	*验证码
	*/

	public function verify(){
		ob_clean();
		$Verify = new  \Think\Verify();// 设置验证码字符为纯数字
		$Verify->fontSize = 60;
		$Verify->fontttf = '5.ttf';
		$Verify->length   = 4;
		$Verify->useNoise = false;
		$Verify->codeSet = '0123456789'; 
		$Verify->entry();

	}
		
    //检验 验证码
    public function check_verify($code, $id = ''){
		$verify = new \Think\Verify();
		return $verify->check($code, $id);
    }	
}